<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>保险代购申请</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="agentForm" action="<%=path%>/ins/agent/batchDown.do" method="post">
        </form>
    </div>
    <input  type="hidden" name="prjId" id="prjId" value="${prjId}"/>
    <input  type="hidden" name="paySchNo" id="paySchNo" value="${paySchNo}"/>
    <div id="agentLigerGrid" class="sq-grid"></div>
</div>

<script type="text/javascript">
	var grid = null;

	$(function(){
		initForm();
		initGrid();
	});
	//初始化表单数据
	function initGrid(){
         var prjId = document.getElementById("prjId").value;
         var paySchNo = document.getElementById("paySchNo").value;
		 grid = $("#agentLigerGrid").ligerGrid({
			 url:'<%=path%>/inscare/insapplication/initInsList.do?prjId='+prjId+'&paySchNo='+paySchNo,
			 method:"get",
			 isSingleCheck: false,
		     parms:getSearchParams(),
			 columns : [
                 {display: '客戶名称', name: 'perNm', width: 150, enabledSort:true,
                     render: function (rowdata, rowindex, value, column) {
                         if(StringUtils.isEmpty(value)){
                             value = "";
                         }
                         var h = '';
                         h='<a href="javascript:showDetail(';
                         h+="'"+rowdata.cstUserId+"'";
                         h+=",'"+rowdata.insPerType+"'";
                         h+=')">'+value+'</a>'
                         return h;
                     }},
			      {display: '分期申请单号', name: 'id', width: 150, enabledSort:true,
                      render: function (rowdata, rowindex, value, column) {
                          var h = '';
                          if (null != value) {
                              h = '<a href="javascript:DetailS(';
                              h += "'" + rowdata.id + "'";
                              h += ')">' + value + '</a>'
                              return h;
                          }
                          return h;
                      }
			      },
                 {display: '保险公司', name: 'insCompNm', width: 200, enabledSort:true},
                 {display: '商业险保费', name: 'plcPriceNm', width: 150, enabledSort:true},
                 {display: '交强险保费', name: 'insPriceNm', width: 150, enabledSort:true},
                 {display: '商业险保险期限', name: 'plcBgTimeNm', width: 250, enabledSort:true},//+至+'insBusiEndDtNm'
                 {display: '交强险保险期限', name: 'insBgTmBsNm', width: 250, enabledSort:true},//+至+'insCompEndDtNm'
                 {display: '被保险人名称', name: 'insPerNm', width: 150, enabledSort:true},
	         ],
		     pageSize:10,
		     root:'rows',
	         record:'total',
	         hideLoadButton : true,
	         width: '100%',
	         height:'100%',
	         heightDiff:-2,
	         checkbox:true,
	         rownumbers:true,
	         onSelectRow: function (rowdata, rowid, rowobj) {
             }
		 });
		 grid = liger.get("agentLigerGrid");
		 grid.setHeight(100);
	}
	
	//初始化form
	function initForm(){
		$("#agentForm").ligerForm({
			validate : true
		});
	}
	
	//查询数据
	function getSearchParams(){
		var form = new liger.get("agentForm");
		var data = form.getData();
		return data;
	}

    /* 申請id详情 */
    function DetailS(id){
        if( StringUtils.isEmpty(id)){
            return false;
        }
        // 跳转到 代购申请  详情页面
        Add_navTab('INS_APPCATION_DETAILS_'+id,'分期申请单表详情','<%=path%>/inscare/insapplication/toAgentDetail.do?applicationId='+id);
    }

    ///* 客戶詳情 */  cstUserId  insPerType
    function showDetail(cstUserId,insPerType){
        //1 自然人  2 法人
        if(insPerType == 1){
             Add_navTab('tab_customer_ins_np_detail'+cstUserId,'客户详情','<%=path%>/customer/cstbscinfo/toCustCstBacInfoNpDetailPage.do?id='+cstUserId);
        }else if(insPerType == 2){
            Add_navTab('tab_customer_ins_corp_detail'+cstUserId,'客户详情','<%=path%>/customer/cstbscinfo/toCustCstBacInfoCorpDetailPage.do?id='+cstUserId);
        }
    }

    function agentSubmission(id) {
        if (!id || id == "") return;
        //var logs = LogUtils.LOG_CUST_LOCK_OPEN_SUCC ;
         logs = "是否确认提交!!!";
         $.ligerDialog.confirm(logs, function (flag) {
            if (flag == false) return;
            //等待对话框
            var wait_dialog;
            //发送ajax请求
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {
                    id: id
                },
                url: '<%=path%>/ins/agentModify/FrozenRow.do',
                //我们通常会在代码中增加对beforsSend时间的处理，比方点击按钮后立刻给出一个‘请求发送中，请稍后的’提示
                beforeSend: function () {
                    //等会对话框
                    wait_dialog = $.ligerDialog.SQalert({
                        content: LogUtils.LOG_CMM_GRID_BTN_ENABLE,
                        SQ_type: "waitting"
                    });
                },
                success: function (msg) {
                    wait_dialog.close();
                    //如果返回成功
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        grid.reload();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }

	/*修改*/
    function agentModify(id){
        if(StringUtils.isEmpty(id)){
            return false;
        }
        // 跳转到 代购修改页面
        Add_navTab('INS_AGENT_MODIFY_'+id,'客户保险代购修改','<%=path%>/ins/agent/toModifyPage.do?applicationId='+id);
    }

	
	//格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }


</script>

</body>
</html>
